﻿using IMeiWei.Model;
using IMeiWeiWebService.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace IMeiWeiWebService.Extensions
{
    public static class businessExtension
    {
        public static Merchant ToMerchant(this business record, string imgUrl, string classTwoName)
        {

            return record == null ? null :
                new Merchant()
                {
                    Address = record.BusinessAddress,
                    AllelicService = record.IsServerAllelic,
                    ImageUrl = imgUrl,
                    MerchantId = record.BusinessId,
                    PerCapita = record.PerCapitaConsumption ?? 0,
                    PhoneNumber = record.BusinessPhone,
                    Distance = 1000,
                    MerchantName = record.BusinessName,
                    ClassTwoName = classTwoName,
                };
        }
    }
}